<?php ob_start();
    
	// display errors, warnings, and notices
	ini_set('max_execution_time', 800); 
	ini_set("display_errors", true);
	ini_set("memory_limit","-1");    
	error_reporting(E_ALL);
    
    //set timezone
    date_default_timezone_set ( 'Asia/Riyadh' );
    
    // requirements
    require("constants.php");
    require("functions.php");
    
    session_start();
    if (!preg_match("{(?:login|logout|register|cron)\.php$}", $_SERVER["PHP_SELF"]))
    {
      if (!isset($_SESSION["user_id"]))
      {
        $_SESSION['error_message'] = "من فضلك قم بتسجيل الدخول أولاً";
        redirect("login.php");
		die();
      }
	  else
	  {
	  //accountant roles
	  if ((!preg_match("{(?:reports|report|loginas|exportExcel|payment|reciept|view-pop-ups/contract|view-pop-ups/fatora)\.php$}", $_SERVER["PHP_SELF"]))&&$_SESSION['r']==3)
	  {
	  $_SESSION['error_message'] = "غير مسموح";
	  redirect("reports.php");
	  die();
	  }
	  elseif((!preg_match("{(?:reports|report|loginas|exportExcel|payment|reciept|view-pop-ups/contract|view-pop-ups/fatora|/apartments|edit-pop-ups/apartment|/editApartment)\.php.*$}", $_SERVER["PHP_SELF"]))&&$_SESSION['r']==4)
	  {
	  $_SESSION['error_message'] = "غير مسموح";
	  redirect("apartments.php");
	  die();
	  }
/* 	  //Employee roles
 	  elseif ((preg_match("{(?:reports|report)\.php$}", $_SERVER["PHP_SELF"]))&&$_SESSION['r']==2)
	  {
	  $_SESSION['error_message'] = "غير مسموح";
	  redirect("index.php");
	  die();
	  } */
	  //General roles
	  elseif (preg_match("{(?:delete|settings|apartments_type|apartments-price|conditions|usersManage)\.php$}", $_SERVER["PHP_SELF"])&&$_SESSION['r']>1)
	  {
	  $_SESSION['error_message'] = "غير مسموح";
	  redirect("index.php");
	  die();
	  }
	  }
    }
    
    //global arrays
    //$apart_status = array("مؤجر","فارغ","تنظيف","صيانة","العقود المنتهية اليوم","محجوز بدون دخول");
   
    $cooler_type= array("سبليت","نافذة","وحدة مركزية");
    $furns_name = array("تلفزيون","مكوى","ثلاجة","مايكرويف","فرن","غسالة","كرسي" ,
				       	"طاولة طعام","سرير","ريسيفر","دولاب ملابس","أدوات مطبخ",
			              "طاولة مكتبية","ادوات زينة","مكيف","اخرى");
    $furn_status = array("مستعمل","جديد","تحت الصيانة");
    $client_type= array("مواطن","مقيم","مواطن خليجى","زائر"); // replace by database table, to be removed
    $payment_method= array("نقدى","حوالة بنكية","شبكة","بطاقة إئتمانية");
    
?>
